VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "ClsBanco"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Public WithEvents orset As ClsRecordset
Attribute orset.VB_VarHelpID = -1

Public Event DataChanged()

Public codigo As String
Public nombre As String
Public sigla As String

'Constructor y Destructor
Private Sub Class_Initialize()
    Set orset = New ClsRecordset
    orset.setCampos dbCampos(ban)
    orset.setTablas Array(ban)
End Sub
Private Sub Class_Terminate()
    Set orset = Nothing
End Sub
' Generic Data management methods
Public Sub consulta()
    orset.consulta
End Sub
Public Sub consultaDatos(codig As String)
    orset.consulta Array(ban_id & "=" & codig)
    orset.CierraRec
End Sub
'metodos de base de datos
Public Sub Nuevo(newNombre As String, newSigla As String)
    orset.sInsert Array("", newSigla, newNombre)
End Sub
Public Sub Modificar(codig As String, newNombre As String, newSigla As String)
    orset.sUpdate Array(codig, newSigla, newNombre)
End Sub

Public Sub Borrar(codig As String)
    orset.sDelete Array(ban_id & "=" & codig)
End Sub
Private Sub Reload_members()
    With orset
        codigo = .getDato(ban_id)
        nombre = .getDato(ban_nombre)
        sigla = .getDato(ban_sigla)
    End With
    RaiseEvent DataChanged
End Sub

Public Sub llenaGrid(Grid As MSHFlexGrid, Optional anchos As Variant, Optional titulos As Variant)
    Dim i As Integer
    With Grid
    'vacia el grid
        .Clear
    'setea numero de columnas y filas
        .Cols = 3
        .Rows = 2
    'coloca datos
        consulta
        If orset.numRegistros > 0 Then
            Set .DataSource = orset.mrec
        End If
        orset.CierraRec
    'setea anchos
        If IsMissing(anchos) Then
            .ColWidth(0) = 75 * 15
            .ColWidth(1) = 0
            .ColWidth(2) = 50 * 15
        Else
            'jala anchos de la variable
            cambiaAnchosHFG Grid, anchos
        End If
    'coloca titulos
        If IsMissing(titulos) Then
            .TextMatrix(0, 0) = "Codigo"
            .TextMatrix(0, 1) = "Sigla"
            .TextMatrix(0, 2) = "Nombre"
        Else
            'jala titulos de la variable
            cambiaTitulosHFG Grid, titulos
        End If
        .Row = 0
    End With
End Sub
Public Sub llenaCombo(cajaCombo As ComboBox, conCodigo As Boolean, conSigla As Boolean)
    Dim i As Integer
    consulta
    i = 0
    cajaCombo.Clear
    If conCodigo Then
        If conSigla Then
            While orset.CanMoveNext
                cajaCombo.AddItem Me.codigo & " - " & Me.sigla & " - " & Me.nombre
                cajaCombo.ItemData(i) = codigo
                orset.MoveNext
                i = i + 1
            Wend
        Else
            While orset.CanMoveNext
                cajaCombo.AddItem Me.codigo & " - " & Me.nombre
                cajaCombo.ItemData(i) = codigo
                orset.MoveNext
                i = i + 1
            Wend
        End If
    Else
        If conSigla Then
            While orset.CanMoveNext
                cajaCombo.AddItem Me.sigla & " - " & Me.nombre
                cajaCombo.ItemData(i) = codigo
                orset.MoveNext
                i = i + 1
            Wend
        Else
            While orset.CanMoveNext
                cajaCombo.AddItem Me.nombre
                cajaCombo.ItemData(i) = codigo
                orset.MoveNext
                i = i + 1
            Wend
        End If
    End If
    If cajaCombo.ListCount > 0 Then
        cajaCombo.ListIndex = 0
    End If
    orset.CierraRec
End Sub
Private Sub orset_DataChanged()
    Reload_members
End Sub
